<?php
    $ob_before='';
    $ob_before=ob_list_handlers();
    if (count($ob_before)>0)
    {
        $PageDocument_Before=ob_get_contents();
        ob_end_clean();
    }
    if (function_exists('PHP_CatchCustomError')==false)
    {
        function PHP_CatchCustomError($output_try)
        {            
            if (preg_match("/<b>(.+?)\serror<\/b>:(.*?)<br/is", $output_try, $match))
            {
                header('HTTP/1.1 500 Internal Server Error');
                $Config_Services=$GLOBALS['Config_Services'];
                return $Config_Services['Debug']==TRUE ? $output_try:$GLOBALS['PHP_CUSTOMERROR'];
            }
            else
            {
                return $output_try;
            }
        }
    }
    ob_start('PHP_CatchCustomError');
    $GLOBALS['PHP_CUSTOMERROR']='HTTP/1.1 500 Internal Server Error';
?>